<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('生成编号')" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-gen-export">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">生成数量：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="number" id="number" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">供应商货箱编号简称：</label>
				<div class="col-sm-8">
					<select id="boxPrefix" name="boxPrefix" class="form-control select2-multiple" required>
						<option th:each="model:${list}" th:value="${model.prefix}" th:text="${model.prefix}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">货箱类型：</label>
				<div class="col-sm-8">
					<select name="goodsBoxSpecId" class="form-control select2-multiple">
						<option th:each="spec : ${specList}" th:text="${spec.specName}" th:value="${spec.id}"></option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
		var prefix = ctx + "system/number";
		$(function() {
			$('#supplierCode').select2({
				placeholder: "请选择供应商简称",
				allowClear: true
			});
			init();
		})

		$("#form-gen-export").validate({
			onkeyup: false,
			rules:{
				number:{
					digits:true,
					max:9997
				},
			},
			focusCleanup: true
		});

		$('input').on('ifChanged', function(obj){
			var type = $(this).val();
			var checked = obj.currentTarget.checked;
			if (type == 1) {
			    if (checked) {
			        $._tree.expandAll(true);
			    } else {
			        $._tree.expandAll(false);
			    }
			} else if (type == "2") {
			    if (checked) {
			        $._tree.checkAllNodes(true);
			    } else {
			        $._tree.checkAllNodes(false);
			    }
			} else if (type == "3") {
			    if (checked) {
			        $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };
			    } else {
			        $._tree.setting.check.chkboxType = { "Y": "", "N": "" };
			    }
			}
		})

		function edit() {
			$.table.generateBoxNumber("form-gen-export");
			/*var roleId = $("input[name='roleId']").val();
			var roleName = $("input[name='roleName']").val();
			var roleKey = $("input[name='roleKey']").val();
			var roleSort = $("input[name='roleSort']").val();
			var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
			var remark = $("input[name='remark']").val();
			$.ajax({
				cache : true,
				type : "POST",
				url : ctx + "system/role/edit",
				data : {
					"roleId": roleId,
					"roleName": roleName,
					"roleKey": roleKey,
					"roleSort": roleSort,
					"status": status,
					"remark": remark,
					"menuIds": menuIds
				},
				async : false,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					$.operate.successCallback(data);
				}
			});*/
		}
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }

		function init() {
			let options = {
				generateUrl: prefix + "/generateBoxNumber",
				modalName: "供应商管理"
			};
			$.table.init(options);
		}
	</script>
</body>
</html>
